/*
 *  SMForwardGraph.h
 *  Seams
 *
 *  Created by Charles Osmer on 4/21/09.
 *  Copyright 2009 __MyCompanyName__. All rights reserved.
 *
 */

#include "SMImage.h"

typedef struct SMForwardGraphNode {
    int value;
    unsigned int maskLevel;

    unsigned int cost;
    struct SMForwardGraphNode *seamEdge;

    struct SMForwardGraphNode *left;
    struct SMForwardGraphNode *right;

    struct SMForwardGraphNode *up;
    struct SMForwardGraphNode *down;
    
} SMForwardGraphNode;

typedef struct {

    const SMImage *image;
    SMForwardGraphNode *nodes;

    unsigned int nSeams;

} SMForwardGraph;

#define SMGraphAssert(g) { assert(g != NULL); assert(g->nodes != NULL); SMImageAssert(g->image); };

extern const SMForwardGraph SMForwardGraph_Initializer;

void SMForwardGraph_Alloc(SMForwardGraph *graph, const SMImage *image);
void SMForwardGraph_Free(SMForwardGraph *graph);

void SMForwardGraph_ResetGraph(SMForwardGraph *graph);
SMImage SMForwardGraph_CarveImage(const SMForwardGraph *graph, const unsigned int level);

int SMForwardGraph_CalculateSeams(SMForwardGraph *graph, unsigned int nMaxSeams);
